import axios from 'axios'

axios.defaults.baseURL = 'http://localhost:8888/api'

// 获取新闻列表
export const getNewsList = () => axios.get('/getnewslist').then(res => res.data)

// 获取新闻详情
export const getNewsDetail = id => axios.get(`/getnew/${id}`).then(res => res.data)

// 获取评论列表数据
export const getCommentList = (id, pageIndex) => axios.get(`/getcomments/${id}?pageindex=${pageIndex}`).then(res => res.data)

// 发表评论 - 这里的content参数和以前post请求传递的参数格式不一样，此处需要的不是json格式，而是content='xxx'&username='xxxxx'
export const postComment = (id, content) => axios.post(`/postcomment/${id}`, content).then(res => res.data)

// 获取图片顶部分类
export const getImgCate = () => axios.get('/getimgcategory').then(res => res.data)

// 根据分类id获取图片列表数据
export const getImgList = id => axios.get(`/getimages/${id}`).then(res => res.data)

// 图文详情缩略图
export const getThumb = id => axios.get(`/getthumimages/${id}`).then(res => res.data)

// 获取缩略图描述
export const getImgInfo = id => axios.get(`/getimageInfo/${id}`).then(res => res.data)

// 获取商品列表
export const getGoodsList = pageindex => axios.get(`/getgoods?pageindex=${pageindex}`).then(res => res.data)

// 获取商品价格及描述
export const getGoodsInfo = id => axios.get(`/goods/getinfo/${id}`).then(res => res.data)

// 获取图文介绍
export const getIntro = id => axios.get(`/goods/getdesc/${id}`).then(res => res.data)

// 获取购物车页面数据
export const getShopInfo = id => axios.get(`/goods/getshopcarlist/${id}`).then(res => res.data)
